package com.rambo.androidnews;

import com.haibin.retrofit.net.PUT;
import com.rambo.androidnews.slice.ArticleDetailAbilitySlice;
import com.rambo.baselib.constant.ParamConstant;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.bundle.IBundleManager;

public class ArticleDetailAbility extends Ability {

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setMainRoute(ArticleDetailAbilitySlice.class.getName());
    }
    ArticleDetailAbilitySlice abilitySlice;
    public void requestPermissionDataSyn(ArticleDetailAbilitySlice abilitySlice) {
        this.abilitySlice = abilitySlice;
        requestPermissionsFromUser(new String[]{ParamConstant.PERMISSION_DATASYN},ParamConstant.PERMISSION_DATASYN_CODE);
    }

    @Override
    protected void onStop() {
        super.onStop();
        abilitySlice = null;
    }

    @Override
    public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsFromUserResult(requestCode, permissions, grantResults);
        if (grantResults != null && grantResults.length > 0) {
            if (abilitySlice != null) {
                abilitySlice.initDistributeDevice();
            }
        }
    }
}
